Telegram Group & Telegram Channel
#Basics

Checking if two words are anagrams

Code:
from collections import Counter
def is_anagram(str1, str2):
return Counter(str1) == Counter(str2)

# or without having to import anything
def is_anagram(str1, str2):
return sorted(str1) == sorted(str2)

print(is_anagram('code', 'doce'))
print(is_anagram('python', 'yton'))

Output:
True
False

Share and Support
@Python_Codes



tg-me.com/python_codes/188
Create:
Last Update:

#Basics

Checking if two words are anagrams

Code:

from collections import Counter
def is_anagram(str1, str2):
return Counter(str1) == Counter(str2)

# or without having to import anything
def is_anagram(str1, str2):
return sorted(str1) == sorted(str2)

print(is_anagram('code', 'doce'))
print(is_anagram('python', 'yton'))

Output:
True
False

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/188

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

Unlimited members in Telegram group now

Telegram has made it easier for its users to communicate, as it has introduced a feature that allows more than 200,000 users in a group chat. However, if the users in a group chat move past 200,000, it changes into "Broadcast Group", but the feature comes with a restriction. Groups with close to 200k members can be converted to a Broadcast Group that allows unlimited members. Only admins can post in Broadcast Groups, but everyone can read along and participate in group Voice Chats," Telegram added.

Python Codes from kr


Telegram Python Codes
FROM USA